package ljl.alg.wangzheng_camp.round1.veryveryeasy;

public class _58_2_rotate_left_words {
    
    /*
     * abcdefg 2
     * cdefgab
     * */
    /**
     * 不太聪明
     * */
    public String reverseLeftWords2(String s, int n) {
        StringBuilder sb = new StringBuilder(s);
        sb.reverse();
        StringBuilder s1 = new StringBuilder(sb.substring(0, s.length() - n));
        s1.reverse();
        StringBuilder s2 = new StringBuilder(sb.substring(s.length() - n));
        s2.reverse();
        return s1.append(s2).toString();
    }
    
    /**
     * 聪明了一些
     * 你也可以一个字符一个字符 append，但是没这个聪明，不写了
     * */
    public String reverseLeftWords(String s, int n) {
        StringBuilder sb = new StringBuilder(s);
        sb.append(s, 0, n);
        return sb.substring(n);
    }
    
}
